/**
 * 试题标签类型枚举
 *
 * @author System
 * @version 2.0.0
 * @since 2025-11-11
 */
package com.edu.exam.enums.questionbank;

import com.edu.exam.enums.core.BaseEnum;

public enum QuestionTagType implements BaseEnum {
    KNOWLEDGE("KNOWLEDGE", "知识点"),
    DIFFICULTY("DIFFICULTY", "难度"),
    TYPE("TYPE", "题型"),
    SKILL("SKILL", "技能"),
    CONCEPT("CONCEPT", "概念"),
    METHOD("METHOD", "方法"),
    CUSTOM("CUSTOM", "自定义");

    private final String code;
    private final String description;

    QuestionTagType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public static QuestionTagType fromCode(String code) {
        for (QuestionTagType type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown question tag type code: " + code);
    }

    public static QuestionTagType fromDescription(String description) {
        for (QuestionTagType type : values()) {
            if (type.getDescription().equals(description)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown question tag type description: " + description);
    }

    @Override
    public String toString() {
        return description;
    }
}